<?php require_once 'header.php';?>    
<!-- DataTables Responsive CSS -->
    <link href="sb2/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">

        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <?php echo XXF_LNAME?>
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <thead>
                                    <tr>
                                        <th>序号</th>
                                        <th>班级名称</th>
                                        <th>新复训</th>
                                        <th>时间</th>
                                        <th>班主任</th>
                                        <th>出题</th>
                                        <th>考试情况</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                	<?php
                                	$i=0;
                                	foreach ($result as $row){$i++;
                                	?>
                                    <tr class="<?php echo $i%2==0?"even":"odd";?> gradeA <?php echo ((date("Y-m-d")>$row['stime'])&&(date("Y-m-d")<$row['etime']))?("success"):""?>" id='<?php echo $row['pid'];?>'>
                                        <td><?php echo $i;?></td>
                                        <td><a href="pxkaoshi/type/kaoshi/pid/<?php echo $row['pid']?>"><?php echo $row['pname'];?></a></td>
                                        <td><?php echo $row['xinfuxun'];?></td>
                                    	<td><?php echo $row['shiqi']."[".substr($row['stime'],5,5).":".substr($row['etime'],5,5)."]";?></td>
                                        <td><?php echo $row['realname'];?></td>
                                        <td><?php echo $row['shifouchuti']!='是'?"<input type='button' value='出题' onclick='chuti(".$row['pid'].")'>":"已出题"?></td>
                                    	<td><?php echo $row['kaiqikaoshi']?></td>
                                    	<td><?php
                                    	if($row['shifouchuti']=='是'&&$row['kaiqikaoshi']=='未开启'){
                                    	    echo "<button onclick='kaoshikaiqi(1,".$row['pid'].")'>开启</button>";
                                    	}elseif($row['shifouchuti']=='是'&&$row['kaiqikaoshi']=='开启'){
                                    	    echo "<button onclick='kaoshikaiqi(0,".$row['pid'].")'>关闭</button>";
                                    	}
                                    	?></td>
                                    </tr>
                                	<?php 
                                	}
                                	?>
                                </tbody>
                            </table>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
             </div>
        </div>
        <!-- /#page-wrapper -->
  </div>
        <!-- DataTables JavaScript -->
<?php require_once 'bottom.php';?>
    <script src="sb2/vendor/datatables/js/jquery.dataTables.js"></script>
    <script src="sb2/vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
    <script src="sb2/vendor/datatables-responsive/dataTables.responsive.js"></script>
    <script>
    $(document).ready(function() {
        $('#dataTables-example').DataTable({
            responsive: true,
            "aaSorting": [[ 0, "desc" ]]
        });
    });
    function kaoshikaiqi(flog,pid){
		$.xpost("pxkaoshi",{
			type:"kaiqi",flog:flog,pid
		},function(data){
			history.go(0);
		});
    }
    function chuti(pid){
		$.xpost("pxkaoshi",{
			type:"chuti1",pid:pid
		},function(data){
			$.xloading(0);
			var jsondata=JSON.parse(data);
			var i=0;
			$.xconfirm("共"+jsondata.length+"人，是否继续出题？",function(data){
				if(data){
					var send=function(fi){
						if(fi<jsondata.length){
							$.xpost("pxkaoshi",{type:"chuti2",pxxyid:jsondata[fi][0],fi:fi,len:jsondata.length,pid:pid},function(data){
								$("#XLOADSTR").html((jsondata.length-i));
								send(++i);
							});
						}else{
							$.xloading(0);
							$.xalert("出题成功！",function(){
								history.go(0);
							});
						}
					}
					send(i);
				}
			});
		});
    }
    </script>